const WOS = require('@lbgfe/wuba-wos').default
/**
 * @class WOS上传
 */
module.exports = class WOSHandlerAdapter {
  /**
    * @typedef {object} WosOptions
    * @property {string} appId
    * @property {string} secretId
    * @property {string} domainHost
    * @property {string} bucket
  */
  /**
   * @param {WosOptions} wosOptions WOS配置
   * @param {String} fileName WOS文件名称
   */
  constructor (wosOptions, fileName) {
    this.wos = new WOS(wosOptions)
    this.fileName = fileName
  }

  handle (sourceMapZipContent) {
    return new Promise((resolve, reject) => {
      // wos
      return this.wos.upload(sourceMapZipContent, this.fileName).then((res) => {
        resolve(res)
      }).catch((err) => {
        reject(err)
      })
    })
  }
}
